// TestWaveView.cpp : implementation of the CTestWaveView class
//

#include "stdafx.h"
#include "TestWave.h"

#include "TestWaveDoc.h"
#include "TestWaveView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView


IMPLEMENT_DYNCREATE(CTestWaveView, CView)

BEGIN_MESSAGE_MAP(CTestWaveView, CView)
	//{{AFX_MSG_MAP(CTestWaveView)
	ON_WM_CREATE()
	ON_WM_HSCROLL()
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView construction/destruction

CTestWaveView::CTestWaveView()
{
	// TODO: add construction code here
	
}

CTestWaveView::~CTestWaveView()
{
}

BOOL CTestWaveView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView drawing

void CTestWaveView::OnDraw(CDC* pDC)
{
	CTestWaveDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	CBrush *pbr = new CBrush, *pbrold;
	pbr->CreateSolidBrush(RGB(0, 0, 0));
	pbrold = pDC->SelectObject(pbr);

	CRect rc;
	GetClientRect(&rc);

	pDC->Rectangle(&rc);

	pDC->SelectObject(pbrold);
	delete pbr;
	

}

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView printing

BOOL CTestWaveView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CTestWaveView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CTestWaveView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView diagnostics

#ifdef _DEBUG
void CTestWaveView::AssertValid() const
{
	CView::AssertValid();
}

void CTestWaveView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTestWaveDoc* CTestWaveView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTestWaveDoc)));
	return (CTestWaveDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTestWaveView message handlers



int CTestWaveView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here

	m_panel.CreateWavePanel(this);
	//p_ctrl = new CGenCtrlBase(CRect(600, 0, 600 + 50, 25), this, 2345);
	p_btn1 = new CMyButton(CRect(900, 0, 900 + 50, 25), this, 1002, _T("Button"));
	p_combo1 = new CMyComboBox(CRect(900, 50, 900 + 100, 50 + 20), this, 1002);
	CString str[3] = {_T("Item1"), _T("Item2"), _T("Item3")};
	p_combo1->InitComboBoxItem(str, 3);
	p_edit = new CMyEdit(CRect(900, 100, 900 + 100, 100 + 20), this, 1003, _T("MyEdit"));
	p_slider= new CMySlider(CRect(900, 150, 900 + 100, 150 + 20), this, 1004, _T(""));
	p_process = new CMyProcessBar(CRect(900, 180, 900 + 100, 180 + 20), this, 1005, _T(""));
	p_checkbox = new CMyCheckBox(CRect(900, 210, 900 + 100, 210 + 20), this, 1006, _T("CheckBox1"));
	p_radiobtn = new CMyRadioBtn(CRect(900, 240, 900 + 100, 240 + 20), this, 1007, _T("RadioBtn1"));
	p_static = new CMyStatic(CRect(900, 270, 900 + 100, 270 + 20), this, 1008, _T("Static1"));

	p_group = new CMyGroupBox(CRect(900, 300, 900 + 200, 300 + 100), this, 1009, _T("Static1"));

	return 0;
}

void CTestWaveView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	// TODO: Add your message handler code here and/or call default
	CMySlider* pScroll=(CMySlider*) pScrollBar;
	CString str;
	if (pScroll->m_ID==1004)
	{
		double lf_percent = nPos/100.0;
		p_process->SetProcessBarPos(lf_percent);
	}
	CView::OnHScroll(nSBCode, nPos, pScrollBar);
}
